package com.jsu.collegestudentadmissionsystem.service.Impl;

import com.jsu.collegestudentadmissionsystem.dao.AcademyDao;
import com.jsu.collegestudentadmissionsystem.pojo.vo.AdmissionInformation;
import com.jsu.collegestudentadmissionsystem.pojo.vo.CollegeMajorInformation;
import com.jsu.collegestudentadmissionsystem.service.AcademyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Scanner;

@Service
public class AcademyServiceImpl implements AcademyService {
    @Autowired
    AcademyDao academyDao;

//    Scanner sc = new Scanner(System.in);
    @Override
    public void insertMajorInformation(String s, String s1, String s2,String s3) {
        academyDao.insertMajorInformation(s,s1,s2,s3);
    }

    @Override
    public void selectiveAdmission() {
        System.out.println("请输入院校专业编号进行录取工作");
        Scanner sc = new Scanner(System.in);
        Integer collegeMajorId = sc.nextInt();
        Integer lineQuantity = academyDao.queryAdminssionQuantity(collegeMajorId);
        List<AdmissionInformation> admissionInformationList = academyDao.selectiveAdmission(collegeMajorId,lineQuantity);
        for(int i=0;i<admissionInformationList.size();i++){
            if(i==0){
                System.out.println("学习专业编号: "+admissionInformationList.get(i).getCollegeMajorId()+"学校： " + admissionInformationList.get(i).getCollegeName() + "专业： " + admissionInformationList.get(i).getMajorName() +
                        "招生人数: " + admissionInformationList.get(i).getAdmissionQuantity()+"\n  录取名单如下");
            }
            System.out.println("     学生ID: " + admissionInformationList.get(i).getStudentId() + "学生名字: " + admissionInformationList.get(i).getStudentName() + "高考总分: " +
                    admissionInformationList.get(i).getTotalScore());
            academyDao.updateAdmissionStatus(admissionInformationList.get(i).getStudentId());
        }
    }

    @Override
    public void queryMajorInformation() {
        List<CollegeMajorInformation> collegeMajorInformationList = academyDao.queryMajorInformation();
        String s1 = "本科一批: \n";
        String s2 = "本科二批: \n";
        String s3 = "专科一批: \n";
        String s4 = "专科二批: \n";
        for(int i=0;i<collegeMajorInformationList.size();i++){
            Integer collegeMajorId = collegeMajorInformationList.get(i).getCollegeMajorId();
            String collegeName = collegeMajorInformationList.get(i).getCollegeName();
            String majorName = collegeMajorInformationList.get(i).getMajorName();
            String batchName = collegeMajorInformationList.get(i).getAdmissionBatchName();
            Integer admissionQuantity = collegeMajorInformationList.get(i).getAdmissionQuantity();
            if(batchName.equals("本科一批")){
                s1=s1+"       院校专业id: "+collegeMajorId+"----"+collegeName+"-----"+majorName+"----招生人数: "+admissionQuantity + "\n";
            }else if(batchName.equals("本科二批")){
                s2=s2+"       院校专业id: "+collegeMajorId+"----"+collegeName+"-----"+majorName+"----招生人数: "+admissionQuantity+ "\n";
            }else if(batchName.equals("专科一批")){
                s3=s3+"       院校专业id: "+collegeMajorId+"----"+collegeName+"-----"+majorName+"----招生人数: "+admissionQuantity+ "\n";
            }else{
                s4=s4+"       院校专业id: "+collegeMajorId+"----"+collegeName+"-----"+majorName+"----招生人数: "+admissionQuantity+ "\n";
            }
        }
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        System.out.println(s4);
    }

    @Override
    public void queryBatchAcademy() {

    }


}

